package com.rosense.srpingboot.controller;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.rosense.srpingboot.entity.Result;
import com.rosense.srpingboot.service.IUserService;
import com.rosense.srpingboot.utils.EchartsUtils;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 
 * @author 李岩飞
 * @email eliyanfei@126.com
 * @date 2018年3月10日 下午6:12:39
 */
@Controller
@Api(tags = "数据分析")
@RequestMapping(value = "data")
public class DataController {
	@Autowired
	IUserService userService;

	@ApiOperation(value = "查看图表数据")
	@RequestMapping(value = "echarts", method = RequestMethod.POST)
	@ResponseBody
	public List<Result> echarts() {
		final List<Result> list = new ArrayList<Result>();
		// 走势图
		Map<String, Object> map2 = new HashMap<String, Object>();
		map2.put("id", "echartId1");
		map2.put("data", "[{value:100,name:'男'},{value:340,name:'女'}]");
		map2.put("legend", "['男','女']");
		String data = EchartsUtils.buildEcharts("pie", map2);
		list.add(Result.ok(data));
		
		map2 = new HashMap<String, Object>();
		map2.put("id", "echartId2");
		map2.put("value", 80);
		data = EchartsUtils.buildEcharts("meter", map2);
		list.add(Result.ok(data));
		
		map2 = new HashMap<String, Object>();
		map2.put("id", "echartId3");
		map2.put("xdata", "['周一','周二','周三','周四','周五','周六']");
		map2.put("data", "[400,244,535,324,545]");
		data = EchartsUtils.buildEcharts("line", map2);
		list.add(Result.ok(data));
		return list;
	}

}
